home *** CD-ROM | disk | FTP | other *** search
- VT-LISP - Very Tiny LISP
-
-
- VT-LISP Version 2.0 is a simple functional LISP interpreter provided
- with full source code to encourage experimentation with LISP,
- functional and object oriented languages.
-
- Startup
-
- 1. Boot the system.
- 2. Insert the disk containing VTLISP.COM in Drive A:
- 3. If the DOS prompt is not A>, type A: and press the ENTER key to switch
- to drive A:.
- 4. Type VTLISP and press RETURN. VTLISP should respond with its heading
- and a '-> ' prompt.
-
- Entering S-expressions.
-
- VT-LISP accepts S-expressions, evaluates them and prints the result of
- the evaluation. You enter an S-expression by typing it directly from the
- keyboard. As you enter S-expressions, the prompt may change to a number
- followed by '>'. The number represents the number of unmatched
- parentheses. For example:
-
- VT-LISP - Copyright 1987 [c] Knowledge Garden Inc.
- -> (cons 'a '(b c))
- (a b c )
- -> (letrec (append '(a b c) '(d e f))
- 1> (append (lambda (x y)
- 3> (if (eq x nil) y
- 4> (cons (car x) (append (cdr x) y))))))
- (a b c d e f )
- ->(read 'b:append) ; read and evaluate the file b:append.lsp
-
- Terminating VT-LISP
-
- 1. To exit VT-LISP, type :
- (exit)
- at the '-> ' prompt.
-
- VT-LISP Grammar
-
- The following BNF describes the syntax of S-expressions
-
- S-expression ::- atom | '(' expression-list ')'
- atom ::- text-string | number
- expression-list ::- S-expression | S-expression '.' S-expression |
- S-expression expression-list
-
- VT-LISP expressions
-
- Variable
- x - upper or lower case identifier, returns the value x if x is bound
-
- Constants
- (QUOTE s) - returns s
- 's
-
- Arithmetic expressions - expr1,expr2 are evaluated before operation is
- performed.
- (ADD expr1 expr2) (+ expr1 expr2)
- (SUB expr1 expr2) (- expr1 expr2)
- (MUL expr1 expr2) (* expr1 expr2)
- (DIV expr1 expr2) (/ expr1 expr2)
- (MOD expr1 expr2)
-
- Comparisons - expr1,expr2 are evaluated before comparison is
- performed.
- (EQ expr1 expr2) - returns T if expr1 evaluates to the same thing as expr2
- (= expr1 expr2)
- (LT expr1 expr2) - returns T if expr1 < expr2
- (< expr1 expr2)
- (GT expr1 expr2) - returns T if expr1 > expr2
- (> expr1 expr2)
- (NEQ expr1 expr2) - returns T if expr1 <> expr2
- (<> expr1 expr2)
- (LE expr1 expr2) - returns T if expr1 <= expr2
- (<= expr1 expr2)
- (GE expr1 expr2) - returns T if expr1 >= expr2
- (>= expr1 expr2)
-
- S-expression operations - expr1, expr2 evaluated before operation is
- performed
- (CONS expr1 expr2) - returns dottted pair (expr1.expr2)
- (CAR expr) - returns first element of expr
- (CDR expr) - returne list formed by removing 1st element from expr
- (ATOM expr) - returns T if expr evaluates to an atom
-
- Conditional expression
- (IF expr1 expr2 expr3) - If expr1 returns T, evaluate expr2, otherwise
- evaluate expr3
-
- Return to DOS
- (EXIT)
-
- Read an expression from a file
- (READ expr) - read an expression from file expr. expr must evaluate to an
- atom which is represents a file name. File names must end
- in ".LSP". Example: (read 'b:append)
- (LOAD expr) - read an entire file. expr must evaluate to an
- atom which is represents a file name. File names must end
- in ".LSP". Example: (read 'b:append). Returns the result of
- the last expression evaluated. This is a convenient method
- of reading in a bunch of DEFUNs at the beginning of a session.
-
- Definition expressions
- (LAMBDA (x1 x2 x3 ....) expr) - define a lambda expression - returns a
- closure repreenting the lambda expression
- bound to the current environment
- (LET expr (x1.expr1) (x2.expr2) .......) - define a block. x1 etc. are
- local variables. expr1, expr2 etc are their deinitions.
- expr1, expr2 etc. are evaluated in current environment,
- independently of one another.
- (LETREC expr (x1.expr1) (x2.expr2) ......) - define a recursive block.
- expr1, expr2 etc. may contain references to one another
- (DEFUN name (x1 x2 ....) expr) - define a global function. Note - the
- sloppy method we have used does not allow nested DEFUNs.
- DEFUN returns the name of the function that has been evaluated.
-
- Function Call
- (expr expr1 expr2 expr3 ...) - evaluate the function expr, using
- parameters expr1 etc. Parameters are
- evaluated before applying the function.
- expr must evaluate to a closure.
-
- Object oriented features
- (make object_name inheritance_list
- (method_selector1 method1) (method_selector2 method2) ....)
- - define an object, inheritance_list is a list of object names
- from which this object inherits methods. None of these
- parameters are evaluated before object is added to the list
- of objects.
-
- (send object_name method_selector) - retreive the value of
- method_selector from object_name and evaluate it.
-
- (send object_name method_selector arg1 arg2 ...) - retrieve the value of
- method_selector from object_name, evaluate the returned value
- and args in the extended environment. The value of
- method_selector should evaluate to a closure. For example,
- (make test (obj1 obj2)
- (cost (lambda (x y) (* x y))))
- and sending the message (send test cost 12 23) will return
- 35.
-
- (send object_name expr) - evaluate expr in the extended environment
- constructed by object_name's inheritance.
-
- Comments
- ; - comments begin with ";". Anything following ";" on a line is ignored
- by the evaluator
-
- Pressing <Ctrl-Break> will abort the current operation and return you to
- the '->' prompt.
-
-
- Good luck with VT-LISP. We would be very interested in hearing of
- your experiments, enhancements or even (gasp) bugs that you may find.
- Please write to us with your comments or questions.
-
- Bill and Bev Thompson
- C/O AI Expert Magazine
- 500 Howard St.
- San Francisco, CA 94105
-
- or on the AI Expert BBS on Compuserv. Our id is BillandBev Thompson,
- [76703,4324]. You can also contact us on BIX, our id is bbt.
-
- Bill and Bev Thompson
-
-
-
-